const tar = ["/pages/index/index", "/pages/user/index", "/pages/Copywriting/index", "/pages/self/list",
	"/pages/cart/cart"
]
export function goNav(url) {

	if (tar.indexOf(url) !== -1) {
		uni.switchTab({
			url: url
		})
	} else if (url.indexOf('/pages/Copywriting') != -1) {
		console.log(url, '11111');
		uni.reLaunch({
			url: url
		})
	} else {
		console.log("jinlaile", url);
		uni.navigateTo({
			url: url
		})
	}
}

export function getPage() {
	let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
	let curRoute = routes[routes.length - 1].route //获取当前页面路由
	let curParam = routes[routes.length - 1].options; //获取路由参数
	// 拼接参数
	let param = ''
	for (let key in curParam) {
		param += '&' + key + '=' + curParam[key]
	}
	let data = {}

	return curRoute + "?" + param;
}

export function parseParams(str) {
	let a = str.split("&");
	let o = {}
	a.forEach(item => {
		let b = item.split('=')
		o[b[0]] = b[1]
	})
	return o
}

export function getPath() {
	return location.protocol + "//" + location.host + location.pathname + '/#/'
}
